package com.question.java.poi;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.File;
import java.io.FileInputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

public class POIUtil {
    public static void main(String[] args) throws Exception {
        Map<String, String> allUrls = new HashMap<String, String>();
        Properties properties = new Properties();
        String[] array = new String[600];

        File file = new File("/Users/junyang/workshop/MeIdeaProjects/question-parent/question-java/src/main/resources/xls/api.xls");
        FileInputStream fileInputStream = new FileInputStream(file);
        boolean is03Excel = "xls/api.xls".matches("^.+\\.(?i)(xlsx)$");
        //1.读取工作簿
        Workbook workbook = is03Excel ? new HSSFWorkbook(fileInputStream) : new XSSFWorkbook(fileInputStream);
        //2.读取工作表
        Sheet sheet = workbook.getSheetAt(0);

        System.out.println("rows: " + sheet.getPhysicalNumberOfRows());
        //跳过前两行
        for (int k = 2; k < sheet.getPhysicalNumberOfRows(); k++) {
            Row row = sheet.getRow(k);
            Cell cell = row.getCell(0);
            System.out.println(cell);

//            allUrls.put("otherUrls", value);
//            array[k] = value;

        }


        System.out.println(allUrls);

    }
}
